<template>
  <div class="reportFormPage">
    <div class="report-dom">
      <el-row>
        <el-col :span="5" :offset="19">
          <div class="pageNumBox">
            <span>第</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.page }}&nbsp;</span>
            <span>页，共</span>
            <span class="placeholder-min text-center">&nbsp;{{ form.totalPage }}&nbsp;</span>
            <span>页</span>
          </div>
        </el-col>
      </el-row>
      <div class="topTwoBox">
        <div class="centerName">石灰密度、未消化残渣含量、含水率、细度试验检测记录表</div>
        <div class="codeText">
          <tr>
            JGLQ09010
          </tr>
          <tr>
            JGLQ09011
          </tr>
          <tr>
            JGLQ09012
          </tr>
          <tr>
            JGLQ09020
          </tr>
        </div>
      </div>
      <div class="threeTopBox">
        <div class="left-border">
          <div class="box-title">检测单位名称：</div>
          <div class>{{ form.jiancdwmc }}</div>
        </div>
        <div class="right-border">
          <span>记录编号：</span>
          <span v-if="isPdf" class="placeholder">{{ form.jilbh }}</span>
          <el-input class="code-input" v-else type="text" v-model="form.jilbh" @focus="handleFocus('jilbh')" />
        </div>
      </div>
      <div class="table-border">
        <!-- .........................1111111111111111111111111111111......................................................... -->
        <table height="220px" class="top-table">
          <tbody>
            <tr>
              <td height="30" align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程名称</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcmc }}</span>
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">工程部位/用途</span>
              </td>
              <td width="35%" class="text-center">
                <span>{{ form.gongcbwyt }}</span>
              </td>
            </tr>
            <tr>
              <td height="50" align="center">样品信息</td>
              <td class="specimen-border" colspan="3">
                <span>样品名称：</span>
                <span :class="{ placeholder: !form.yangpmc }">{{ form.yangpmc }}</span>
                <span>；样品编号：</span>
                <span :class="{ 'placeholder-long': !form.yangpbh }">{{ form.yangpbh }}</span>
                <span>；样品数量：</span>
                <span :class="{ placeholder: !form.yangpsl }">{{ form.yangpsl }}</span>
                <span>；样品状态：</span>
                <span :class="{ placeholder: !form.yangpzt }">{{ form.yangpzt }}</span>
                <span>；来样时间：</span>
                <span :class="{ placeholder: !form.yangpsj }">{{ form.yangpsj }}</span>
              </td>
            </tr>

            <tr>
              <td height="25" align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验检测日期</span>
              </td>
               <!-- <td width="35%" class="text-center">{{ form.shiyjcrq }}</td> -->                                            
 <td width="35%" class="text-center">
      <el-input v-model="form.shiyjcrq" />
</td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">试验条件</span>
              </td>
              <td v-if="isPdf" width="35%">
                温度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjwd }}</span>
                ℃；湿度：
                <span style="display: inline-block; width: 10%">{{ form.shiytjsd }}</span
                >%RH
              </td>
              <td v-else width="35%">
                温度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjwd" style="width: 15%" />℃；湿度：
                <el-input :type="isPdf ? 'string' : 'number'" v-model="form.shiytjsd" style="width: 15%" />%RH
              </td>
            </tr>

            <tr>
              <td height="50" align="center" width="15%">
                <span style="width: 90px; display: inline-block">检测依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.jiancyj }}</span>
                <el-input v-else type="textarea" v-model="form.jiancyj" :rows="2" class="mark" @dblclick.native="showBsJiancyjView" readonly />
              </td>
              <td align="center" width="15%">
                <span style="width: 90px; display: inline-block">判定依据</span>
              </td>
              <td width="35%">
                <span v-if="isPdf">{{ form.pandyj }}</span>
                <el-input v-else type="textarea" v-model="form.pandyj" :rows="2" @dblclick.native="showBsJudgeBaseView" @focus="handleFocus('pandyj')" class="mark" />
              </td>
            </tr>
            <tr class="bottom-border">
              <td height="50" align="center">
                <div>主要仪器设备</div>
                <div>名称及编号</div>
              </td>
              <td colspan="3">
                <span v-if="isPdf">{{ form.zhuyyqsbmcjbh }}</span>
                <el-input v-else type="textarea" :rows="2" v-model="form.zhuyyqsbmcjbh" class="height100 width100 mark" @dblclick.native="showBsInstrumentView" readonly></el-input>
              </td>
            </tr>
          </tbody>
        </table>
        <!-- .................................22222222222222222222222222222222............................................... -->
        <table height="616px" class="middle-table">
          <tbody>
            <tr height="25">
              <td colspan="10">含水量</td>
            </tr>
            <tr height="25">
              <td width="10%" rowspan="2">盒号</td>
              <td rowspan="2">盒质量(g)</td>
              <td rowspan="2">盒+湿样质量(g)</td>
              <td rowspan="2">盒+干样质量(g)</td>
              <td rowspan="2">水分质量(g)</td>
              <td rowspan="2">干试样质量(g)</td>
              <td colspan="4">含水量(%)</td>
            </tr>
            <tr height="25">
              <td colspan="2">单值</td>
              <td colspan="2">平均值</td>
            </tr>
            <tr height="25">
              <!-- <td>1</td> -->
              <td width="10%"><el-input v-model="form.heh1" class="pointer mark" @dblclick.native="showBaQjDetailView(1)" readonly /></td>
              <td><el-input type="number" v-model="form.hezl1" @change="countHsl(1)" disabled /></td>
              <td><el-input type="number" v-model="form.hesyzl1" @change="countHsl(1)" @keydown.native="handleKeyDown($event, 0, 0)" :ref="'0_0'" /></td>
              <td><el-input type="number" v-model="form.hegyzl1" @change="countHsl(1)" @keydown.native="handleKeyDown($event, 0, 1)" :ref="'0_1'" /></td>
              <td><el-input type="number" v-model="form.shuifzl1" disabled /></td>
              <td><el-input type="number" v-model="form.gansyzl1" disabled /></td>
              <td colspan="2"><el-input type="number" v-model="form.hansldz1" disabled /></td>
              <td colspan="2" rowspan="2"><el-input type="number" v-model="form.hanslpjz" disabled /></td>
            </tr>
            <tr height="25">
              <!-- <td>1</td> -->
              <td width="10%"><el-input v-model="form.heh2" class="pointer mark" @dblclick.native="showBaQjDetailView(2)" readonly /></td>
              <td><el-input type="number" v-model="form.hezl2" @change="countHsl(2)" disabled /></td>
              <td><el-input type="number" v-model="form.hesyzl2" @change="countHsl(2)" @keydown.native="handleKeyDown($event, 1, 0)" :ref="'1_0'" /></td>
              <td><el-input type="number" v-model="form.hegyzl2" @change="countHsl(2)" @keydown.native="handleKeyDown($event, 1, 1)" :ref="'1_1'" /></td>
              <td><el-input type="number" v-model="form.shuifzl2" disabled /></td>
              <td><el-input type="number" v-model="form.gansyzl2" disabled /></td>
              <td colspan="2"><el-input type="number" v-model="form.hansldz2" disabled /></td>
            </tr>
            <tr height="25">
              <td colspan="10">密度</td>
            </tr>
            <tr height="25">
              <td rowspan="2">试验次数</td>
              <td rowspan="2">试验温度(℃)</td>
              <td rowspan="2">t(℃)时水的密度(g/cm³)</td>
              <td colspan="2">器皿及石灰干燥质量(g)</td>
              <td colspan="2">比重瓶读数(ml)</td>
              <td colspan="2">石灰密度(g/cm³)</td>
              <td rowspan="2">石灰相对密度</td>
            </tr>
            <tr height="25">
              <td>试验前</td>
              <td>试验后</td>
              <td>加石灰前</td>
              <td>加石灰后</td>
              <td>单值</td>
              <td>平均值</td>
            </tr>
            <tr height="25">
              <td>1</td>
              <td>
                <el-select v-model="form.shiywd1" class="hide-icon height100" placeholder @change="miduChange(1)">
                  <el-option v-for="(item, index) in miduList" :key="index" :label="item.temp" :value="item.temp"></el-option>
                </el-select>
                <!-- <el-input type="number" v-model="form.shiywd1" /> -->
              </td>
              <td><el-input type="number" v-model="form.shuidmd1" disabled /></td>
              <td><el-input type="number" v-model="form.shiyq1" @change="countMddz(1)" @keydown.native="handleKeyDown($event, 2, 0)" :ref="'2_0'" /></td>
              <td><el-input type="number" v-model="form.shiyh1" @change="countMddz(1)" @keydown.native="handleKeyDown($event, 2, 1)" :ref="'2_1'" /></td>
              <td><el-input type="number" v-model="form.jiashq1" @change="countMddz(1)" @keydown.native="handleKeyDown($event, 2, 2)" :ref="'2_2'" /></td>
              <td><el-input type="number" v-model="form.jiashh1" @change="countMddz(1)" @keydown.native="handleKeyDown($event, 2, 3)" :ref="'2_3'" /></td>
              <td><el-input type="number" v-model="form.shihmddz1" disabled /></td>
              <td rowspan="2"><el-input type="number" v-model="form.shihmdpjz1" disabled /></td>
              <td rowspan="2"><el-input type="number" v-model="form.shihxdmd" disabled /></td>
            </tr>
            <tr height="25">
              <td>2</td>
              <td>
                <el-select v-model="form.shiywd2" class="hide-icon height100" placeholder @change="miduChange(2)">
                  <el-option v-for="(item, index) in miduList" :key="index" :label="item.temp" :value="item.temp"></el-option>
                </el-select>
                <!-- <el-input type="number" v-model="form.shiywd2" /> -->
              </td>
              <td><el-input type="number" v-model="form.shuidmd2" disabled /></td>
              <td><el-input type="number" v-model="form.shiyq2" @change="countMddz(2)" @keydown.native="handleKeyDown($event, 3, 0)" :ref="'3_0'" /></td>
              <td><el-input type="number" v-model="form.shiyh2" @change="countMddz(2)" @keydown.native="handleKeyDown($event, 3, 1)" :ref="'3_1'" /></td>
              <td><el-input type="number" v-model="form.jiashq2" @change="countMddz(2)" @keydown.native="handleKeyDown($event, 3, 2)" :ref="'3_2'" /></td>
              <td><el-input type="number" v-model="form.jiashh2" @change="countMddz(2)" @keydown.native="handleKeyDown($event, 3, 3)" :ref="'3_3'" /></td>
              <td><el-input type="number" v-model="form.shihmddz2" disabled /></td>
            </tr>
            <tr height="25">
              <td colspan="10">细度</td>
            </tr>
            <tr height="25">
              <td>项目</td>
              <td colspan="2">样品质量m(g)</td>
              <td colspan="2">0.6mm筛余物质量m1(g)</td>
              <td colspan="3">0.15mm筛余物质量m2(g)</td>
              <td>X1(%)</td>
              <td>X2(%)</td>
            </tr>
            <tr height="25">
              <td>第一次</td>
              <td colspan="2"><el-input type="number" v-model="form.yangpzl1" @change="countXdX(1)"  @keydown.native="handleKeyDown($event, 4, 0)" :ref="'4_0'"/></td>
              <td colspan="2"><el-input type="number" v-model="form.m11" @change="countXdX(1)"  @keydown.native="handleKeyDown($event, 4, 1)" :ref="'4_1'"/></td>
              <td colspan="3"><el-input type="number" v-model="form.m21" @change="countXdX(1)"  @keydown.native="handleKeyDown($event, 4, 2)" :ref="'4_2'"/></td>
              <td><el-input type="number" v-model="form.x11" disabled /></td>
              <td><el-input type="number" v-model="form.x21" disabled /></td>
            </tr>
            <tr height="25">
              <td>第二次</td>
              <td colspan="2"><el-input type="number" v-model="form.yangpzl2" @change="countXdX(2)"  @keydown.native="handleKeyDown($event, 5, 0)" :ref="'5_0'"/></td>
              <td colspan="2"><el-input type="number" v-model="form.m12" @change="countXdX(2)"  @keydown.native="handleKeyDown($event, 5, 1)" :ref="'5_1'"/></td>
              <td colspan="3"><el-input type="number" v-model="form.m22" @change="countXdX(2)"  @keydown.native="handleKeyDown($event, 5, 2)" :ref="'5_2'"/></td>
              <td><el-input type="number" v-model="form.x12" disabled /></td>
              <td><el-input type="number" v-model="form.x22" disabled /></td>
            </tr>
            <tr height="25">
              <td>第三次</td>
              <td colspan="2"><el-input type="number" v-model="form.yangpzl3" @change="countXdX(3)"  @keydown.native="handleKeyDown($event, 6, 0)" :ref="'6_0'"/></td>
              <td colspan="2"><el-input type="number" v-model="form.m13" @change="countXdX(3)"  @keydown.native="handleKeyDown($event, 6, 1)" :ref="'6_1'"/></td>
              <td colspan="3"><el-input type="number" v-model="form.m23" @change="countXdX(3)"  @keydown.native="handleKeyDown($event, 6, 2)" :ref="'6_2'"/></td>
              <td><el-input type="number" v-model="form.x13" disabled /></td>
              <td><el-input type="number" v-model="form.x23" disabled /></td>
            </tr>
            <tr height="25">
              <td colspan="8">平均值</td>
              <td><el-input type="number" v-model="form.xidpjz1" disabled /></td>
              <td><el-input type="number" v-model="form.xidpjz2" disabled /></td>
            </tr>
            <tr height="25">
              <td colspan="10">未消解颗粒含量</td>
            </tr>
            <tr height="25">
              <td rowspan="2">试样编号</td>
              <td colspan="3" rowspan="2">试样干质量(g)</td>
              <td colspan="4">未消解颗粒(>2.36mm)</td>
              <td colspan="2" rowspan="2">未消解颗粒含量(%)</td>
            </tr>
            <tr height="25">
              <td colspan="2">干质量(g)</td>
              <td colspan="2">百分比(%)</td>
            </tr>
            <tr height="25">
              <td>1</td>
              <td colspan="3"><el-input type="number" v-model="form.shiygzl1" @change="countWxjklhl(1)"  @keydown.native="handleKeyDown($event, 7, 0)" :ref="'7_0'"/></td>
              <td colspan="2"><el-input type="number" v-model="form.ganzl1" @change="countWxjklhl(1)"  @keydown.native="handleKeyDown($event, 7, 1)" :ref="'7_1'"/></td>
              <td colspan="2"><el-input type="number" v-model="form.baifb1" disabled /></td>
              <td colspan="2" rowspan="3"><el-input type="number" v-model="form.weixjklhl" disabled /></td>
            </tr>
            <tr height="25">
              <td>2</td>
              <td colspan="3"><el-input type="number" v-model="form.shiygzl2" @change="countWxjklhl(2)"  @keydown.native="handleKeyDown($event, 8, 0)" :ref="'8_0'"/></td>
              <td colspan="2"><el-input type="number" v-model="form.ganzl2" @change="countWxjklhl(2)"  @keydown.native="handleKeyDown($event, 8, 1)" :ref="'8_1'"/></td>
              <td colspan="2"><el-input type="number" v-model="form.baifb2" disabled /></td>
            </tr>
            <tr height="25">
              <td>3</td>
              <td colspan="3"><el-input type="number" v-model="form.shiygzl3" @change="countWxjklhl(3)"  @keydown.native="handleKeyDown($event, 9, 0)" :ref="'9_0'"/></td>
              <td colspan="2"><el-input type="number" v-model="form.ganzl3" @change="countWxjklhl(3)"  @keydown.native="handleKeyDown($event, 9, 1)" :ref="'9_1'"/></td>
              <td colspan="2"><el-input type="number" v-model="form.baifb3" disabled /></td>
            </tr>
          </tbody>
        </table>
        <!-- .....................................................33333333333333333................................................... -->
        <table height="30px" class="bottom-table">
          <tr>
            <td>
              <span v-if="isPdf" class="textarea-span">{{ form.fujsm }}</span>
              <el-input v-else type="textarea" :rows="2" v-model="form.fujsm" @focus="handleFocus('fujsm')" />
            </td>
          </tr>
        </table>
      </div>
      <!-- .................................44444444444............................................. -->
      <table height="22px" class="transparent">
        <tbody>
          <tr>
            <td width="10%" align="right">检测：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">记录：</td>
            <td width="15%" align="left"></td>
            <td width="10%" align="right">复核：</td>
            <td align="left" width="15%"></td>
            <td width="10%">日期：</td>
            <td align="left" width="15%">
              <div style="display: inline-block; margin-left: 20px">年</div>
              <div style="display: inline-block; margin-left: 20px">月</div>
              <div style="display: inline-block ;margin-left: 20px">日</div>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
    <bs-instrument-view ref="bsInstrumentViewRef" @select="selectInstrument"></bs-instrument-view>
    <bs-jiancyj-view ref="bsJiancyjViewRef" @select="selectJiancyj" :syType="syType"></bs-jiancyj-view>
    <bs-judge-base-view ref="bsJudgeBaseViewRef" @select="selectJudge" :syType="syType"></bs-judge-base-view>
    <ba-qj-detail-view ref="baQjDetailViewRef" :excelId="excelId" :shiyjcrq="form.shiyjcrq" @select="selectBaQjDetail"></ba-qj-detail-view>
  </div>
</template>

<script>
import {
  listShShmdwxhczhlhslxdjlbBsInfo,
  getShShmdwxhczhlhslxdjlbBsInfo,
  delShShmdwxhczhlhslxdjlbBsInfo,
  addShShmdwxhczhlhslxdjlbBsInfo,
  updateShShmdwxhczhlhslxdjlbBsInfo
} from "@/api/report_sh/shShmdwxhczhlhslxdjlbBsInfo";
import BsInstrumentView from "@/views/dept/bsInstrument/BsInstrumentView.vue";
import BaQjDetailView from "@/views/sycs/baQjDetail/BaQjDetailView.vue";
import BsJiancyjView from "@/views/sycs/bsJiancyj/BsJiancyjView.vue";
import BsJudgeBaseView from "@/views/sycs/bsJudgeBase/BsJudgeBaseView.vue";
import { listBySyTypeId } from "@/api/sycs/dataBase";

import decimal from "@/utils/big-decimal";
import { handleFocus, emptyConvert, calculateMeanvalue, handleKeyDown } from "@/views/reportForms/utils";
import Bus from "@/utils/bus";
import { countBy } from "lodash";
export default {
  name: "shmdwxhczhlhslxdjlb",
  components: {
    BsInstrumentView,
    BaQjDetailView,
    BsJiancyjView,
    BsJudgeBaseView
  },
  props: {
    excelId: {
      type: [String, Number],
      default: () => ""
    },
    syType: {
      type: [String, Number],
      default: () => ""
    },
    page: {
      type: Number,
      default: () => 0
    },
    isPdf: {
      type: Boolean,
      default: () => false
    },
    printEmpty: {
      type: Boolean,
      default: () => false
    }
  },
  data() {
    return {
      params: {},
      query: {},
      miduList: [],
      // 表单参数
      form: {
        detailList: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
      },
      hehIdList: []
    };
  },
  watch: {
    isPdf(newVal, oldVal) {
      this.form = { ...emptyConvert(this.form, newVal) };
    }
  },
  created() {
    this.getInfo();
    this.getShuiwenList();
  },
  methods: {
    // 获取详情
    getInfo() {
      getShShmdwxhczhlhslxdjlbBsInfo(this.excelId || this.$defaultExcelId).then((response) => {
        this.form = response.data;
        if (!this.form.fujsm) {
          this.form.fujsm = "附加声明：";
        }
      });
    },
    // 显示检测依据列表
    showBsJiancyjView() {
      this.$refs.bsJiancyjViewRef.init(this.form.jiancyjIds);
    },
    // 检测依据选择
    selectJiancyj(info) {
      this.form.jiancyj = info.label;
      this.form.jiancyjIds = info.ids;
      Bus.$emit("setShsyBgJiancyj", { jiancyj: this.form.jiancyj, jiancyjIds: this.form.jiancyjIds });
    },
    // 显示判定依据列表
    showBsJudgeBaseView() {
      this.$refs.bsJudgeBaseViewRef.init(this.form.pandyjIds);
    },
    // 判断依据选择
    selectJudge(info) {
       this.form.pandyjIds = info.ids;
      this.form.pandyj = info.label;
    },
    // 显示仪器列表
    showBsInstrumentView() {
      this.$refs.bsInstrumentViewRef.init(this.form.shebIds);
    },
    // 仪器选择
    selectInstrument(info) {
      this.form.zhuyyqsbmcjbh = info.label;
      this.form.shebIds = info.ids;
      Bus.$emit("setShsyBgZhuyyqsbmcjbh", { zhuyyqsbmcjbh: this.form.zhuyyqsbmcjbh, shebIds: this.form.shebIds });
    },

    handleFocus(event) {
      handleFocus(event, this.page, this.form[event]);
    },
    submitForm() {
      this.collectHehId();
      return this.form;
    },
    // 密度
    getShuiwenList() {
      listBySyTypeId({ syYjId: "281757153833" }).then((response) => {
        const data = response.data;
        this.miduList = data.page.records;
      });
    },
    miduChange(type) {
      const info = this.miduList.find((item) => item.temp == this.form["shiywd" + type]);
      if (!info) {
        return;
      }
      this.form["shuidmd" + type] = info.density;
      if (type == 1) {
        this.countMdPjz();
      }
    },
    countMddz(type) {
      let a = this.form["shiyq" + type]; //试验前
      let b = this.form["shiyh" + type]; //试验后
      let c = this.form["jiashq" + type]; //加石灰前
      let d = this.form["jiashh" + type]; //加石灰后
      if (a != null && b != null && c != null && d != null) {
        let E = (a - b) / (d - c);
        this.form["shihmddz" + type] = decimal.round(E, 3);
        this.countMdPjz();
      }
    },
    countMdPjz() {
      let a1 = this.form.shihmddz1;
      let a2 = this.form.shihmddz2;
      let x = this.form.shuidmd1;

      if (a1 != null && a2 != null) {
        this.form.shihmdpjz1 = calculateMeanvalue([a1, a2], 3);
        this.setBusArr(85, this.form.shihmdpjz1);
      } else if (a1 != null) {
        this.form.shihmdpjz1 = calculateMeanvalue([a1], 3);
        this.setBusArr(85, this.form.shihmdpjz1);
      } else if (a2 != null) {
        this.form.shihmdpjz1 = calculateMeanvalue([a2], 3);
        this.setBusArr(85, this.form.shihmdpjz1);
      }
      if (x != null) {
        let y = this.form.shihmdpjz1 / x;
        this.form.shihxdmd = decimal.round(y, 3);
      }
    },
    // 含水量
    // 显示盒号列表
    showBaQjDetailView(type) {
      this.collectHehId();
      this.$refs.baQjDetailViewRef.init(type, this.hehIdList);
    },
    // 盒号选择
    selectBaQjDetail(type, obj) {
      this.form["heh" + type] = obj.hh;
      this.form["hehId" + type] = obj.detailId;
      this.form["hezl" + type] = obj.quality;
      this.countHsl(type);
    },
    // 汇总盒号id
    collectHehId() {
      let hehIdList = [];
      for (let i = 1; i <= 2; i++) {
        if (this.form["heh" + i]) {
          hehIdList.push(this.form["hehId" + i]);
        }
      }
      this.hehIdList = hehIdList;
    },
    countHsl(type) {
      let b = this.form["hezl" + type]; //盒质量(g)
      let c = this.form["hesyzl" + type]; //盒+湿样质量(g)
      let d = this.form["hegyzl" + type]; //盒+干样质量(g)
      if (b != null && c != null && d != null) {
        this.form["shuifzl" + type] = decimal.subtract(c, d, 2); //G
        this.form["gansyzl" + type] = decimal.subtract(d, b, 2); //H
        let I = (this.form["shuifzl" + type] / this.form["gansyzl" + type]) * 100;
        this.form["hansldz" + type] = decimal.round(I, 1);
        this.countHslPjz();
      }
    },
    countHslPjz() {
      let a1 = this.form.hansldz1;
      let a2 = this.form.hansldz2;
      if (a1 != null && a2 != null) {
        this.form.hanslpjz = calculateMeanvalue([a1, a2], 1);
        this.setBusArr(86, this.form.hanslpjz);
      } else if (a1 != null) {
        this.form.hanslpjz = calculateMeanvalue([a1], 1);
        this.setBusArr(86, this.form.hanslpjz);
      } else if (a2 != null) {
        this.form.hanslpjz = calculateMeanvalue([a2], 1);
        this.setBusArr(86, this.form.hanslpjz);
      }
    },
    // 细度
    countXdX(type) {
      let a = this.form["yangpzl" + type]; //样品质量m(g)
      let b = this.form["m1" + type]; //0.6mm筛余物质量m1(g)
      let c = this.form["m2" + type]; //0.15mm筛余物质量m2(g)
      if (a != null && b != null && c != null) {
        let X1 = (100 * b) / a;
        let X2 = (100 * (b + c)) / a;
        this.form["x1" + type] = decimal.round(X1, 2);
        this.form["x2" + type] = decimal.round(X2, 2);
        this.countXdPjz();
      }
    },
    countXdPjz() {
      let a1 = this.form.x11;
      let a2 = this.form.x12;
      let a3 = this.form.x13;
      let b1 = this.form.x21;
      let b2 = this.form.x22;
      let b3 = this.form.x23;

      let aArr = [a1, a2, a3];
      let bArr = [b1, b2, b3];
      aArr = aArr.filter((v) => v != null);
      bArr = bArr.filter((v) => v != null);
      this.form.xidpjz1 = calculateMeanvalue(aArr, 2);
      this.form.xidpjz2 = calculateMeanvalue(bArr, 2);
      this.setBusArr(87, this.form.xidpjz1);
      this.setBusArr(88, this.form.xidpjz2);
    },
    // 未消解颗粒含量
    countWxjklhl(type) {
      let a = this.form["shiygzl" + type];
      let b = this.form["ganzl" + type];
      if (a != null && b != null) {
        let C = (b / a) * 100;
        this.form["baifb" + type] = decimal.round(C, 1);
        this.countWxjklhlPjz();
      }
    },
    countWxjklhlPjz() {
      let a1 = this.form.baifb1;
      let a2 = this.form.baifb2;
      let a3 = this.form.baifb3;
      let arr = [a1, a2, a3];
      arr = arr.filter((v) => v != null);
      this.form.weixjklhl = calculateMeanvalue(arr, 1);
      this.setBusArr(92, this.form.weixjklhl);
    },
    // 传值
    setBusArr(num, data) {
      Bus.$emit("setShsyjcbg", [
        {
          key: num,
          value: data
        }
      ]);
    },
    handleKeyDown(event, rowIndex, colIndex) {
      const maxArr = [1, 1, 3, 3, 2, 2, 2, 1, 1];
      const ref = handleKeyDown(event, rowIndex, colIndex, maxArr);
      if (this.$refs[ref]) {
        this.$refs[ref].focus();
      }
    }
  }
};
</script>

<style scoped>
</style>
